package com.community.contents.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.community.common.core.utils.Result;
import com.community.contents.entity.CategoryEntity;
import com.community.contents.service.ICategoryService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 类目
 *
 * @author hjs hjs@qq.com
 * @since 1.0.0 2023-02-21
 */
@RestController
@RequestMapping("contents/category")
@Api(tags="类目")
@Slf4j
public class CategoryController {
    @Autowired
    private ICategoryService categoryService;

    @PostMapping("page")
    public Result<Page<CategoryEntity>> page(@RequestBody Page<CategoryEntity> params){
        Page<CategoryEntity> page = categoryService.page(params);
        return new Result<Page<CategoryEntity>>().ok(page);
    }

    @PostMapping
    public boolean save(@RequestBody CategoryEntity dto){

        return categoryService.save(dto);
    }

    //获取所有类目--view展示
    @GetMapping("classList")
    public Result classList(){
        return new Result().ViewOk(categoryService.list());
    }


}